Continuing quest for graphing.....

by: davidjackson1955, 9 years ago


Ok, Here's my scrip(bases on first three  Panda tutorials)

       import matplotlib.pyplot as plt
       from matplotlib import style
       import pandas as pd
        style.use('fivethirtyeight')
        df = pd.read_csv('~/python/43068.csv')
        df.set_index('Date', inplace = True)
        # It works to here
        df['Value'].plot()
         plt.legend()
         plt.show()

I was working, but after I sorted the csv file it's not?

Here's some data:
Date, Value
1996-04-30,109275.5
1996-05-31,104994.5
1996-06-30,103020.0
1996-07-31,111447.5
1996-08-31,114662.7
1996-09-30,108069.7
1996-10-31,95700.0
1996-11-30,104185.0



You must be logged in to post. Please login or register an account.



A CSV is purely a comma, not a comma and space by default. You can make the splitter something else, but your data is just a comma. You have that clear in your data, but your column header has a ', ' (comma, space). Thus, the column header is not "Value" ... it is " Value."

Date, Value
should be
Date,Value


You can always get a clean look, by doing:
print(df.columns)
which gives you
Index([' Value'], dtype='object')
and it's a little easier to see little things like that in the code.




-Harrison 9 years ago

You must be logged in to post. Please login or register an account.